//Triangle.cpp
//Contains the function definitions for the Triangle Class

#include <iostream>
#include "Triangle.h"
#include "Random.h"

using namespace std;

Triangle::Triangle(const float &p_X, const float &p_Y, float s_A, float s_B, float s_C)
	: NonCircularShapes(p_X, p_Y)
{
	setSides(s_A, s_B, s_C);
	setArea(sideA, sideB, sideC);
	setPerimeter(sideA, sideB, sideC);
	setShapeType("Triangle");
}

Triangle::Triangle()
	: NonCircularShapes()
{

}

void Triangle::setSides(float s_A, float s_B, float s_C)
{
	sideA = s_A;
	sideB = s_B;
	sideC = s_C;
}

float Triangle::getSideA() const
{
	return sideA;
}

float Triangle::getSideB() const
{
	return sideB;
}

float Triangle::getSideC() const
{
	return sideC;
}

bool Triangle::validateTriangle(float s_A, float s_B, float s_C)
{
	if(s_A + s_B > s_C && s_A + s_C > s_B && s_B + s_C > s_A)
	{
		return true;
	}
	else
	{
		return false;
	}
}

void Triangle::setArea(float s_A, float s_B, float s_C)
{
	float s;

	s = (s_A + s_B + s_C)/2;

	T_area = sqrt(s * (s-s_A) * (s-s_B) * (s-s_C)); 
}

float Triangle::getArea() const
{
	return T_area;
}

void Triangle::setPerimeter(float s_A, float s_B, float s_C)
{
	T_perimeter = s_A + s_B + s_C;
}

float Triangle::getPerimeter() const
{
	return T_perimeter;
}

float Triangle::area() const
{
	return getArea();
}

float Triangle::perimeter() const
{
	return getPerimeter();
}

float Triangle::volume() const
{
	return 0.0;
}

